package com.open.capacity.points.controller;

import com.open.capacity.common.constant.PointsRuleConstant;
import com.open.capacity.common.exception.controller.ControllerException;
import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.log.annotation.LogAnnotation;
import com.open.capacity.points.service.PointsLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("pointsLog")
@Api(tags = "POINTS-LOG API")
public class PointsLogController {

    @Resource
    private PointsLogService pointsLogService;

    @GetMapping("/getPointsLog")
    @ApiOperation(value = "根据条件，返回积分日志")
    @LogAnnotation(module = "points-center")
    public PageResult getPointsLog(@RequestParam Map<String, Object> params) throws ControllerException {
        try {
            return pointsLogService.findPointsLogByCondition(params);
        } catch (ServiceException e) {
            throw new ControllerException(e);
        }
    }
}
